package cool.taomu.toolkit.kademlia

import cool.taomu.toolkit.Context
import cool.taomu.toolkit.TaomuConfigure
import cool.taomu.toolkit.TaomuGuice
import cool.taomu.toolkit.TaomuGuiceServiceLoader
import cool.taomu.toolkit.crypto.Base64
import cool.taomu.toolkit.jsch.service.JschUtils
import java.util.concurrent.TimeUnit
import org.slf4j.LoggerFactory

class Application {
	val static LOG = LoggerFactory.getLogger(Application);

	def static main(String[] args) {
		entry();
	}

	def static void entry() {
		 val TaomuConfigure config = new TaomuConfigure(new Base64())
        config.loadConfig
        var injector = TaomuGuice.createInjector(config)
        TaomuGuiceServiceLoader.loadIPlatform(injector, config)
		var subInjector =  injector.getInstance(Context).injectorSupplier.get()
		var jsch = subInjector.getInstance(JschUtils);
		/*var sshproxy = jsch.portForwarding("proxy")
		if(sshproxy !== null){
			sshproxy.portForwarding();
		}*/
		while (true) {
			try {
				 TimeUnit.HOURS.sleep(24)
			} catch (InterruptedException e) {
				Thread.currentThread().interrupt();
				System.err.println("Thread interrupted");
				return;
			}
		}
	}

}
